# encoding: utf-8

import pandas as pd

class PadasExcelUtil:
    def __init__(self,filename,type="excel"):
        self.__filename = filename
        try:
            if type == "html":
                self.__data = pd.read_csv(self.__filename,encoding='gb2312')
            else:
                self.__data = pd.read_excel(self.__filename)
        except FileNotFoundError:
            print(self.__filename + " not find")
            self.__data = []

    def getAllData(self):
        return self.__data

    def deleteByLine(self,linenum):
        self.__data = self.__data.drop(linenum)

    def deleteByColumn(self,columnname):
        self.__data = self.__data.drop(columnname,axis=1)

    def save(self,newfilename):
        # 导出excel
        self.__data.to_excel(newfilename)